Skip to content

Conversation

@jstac
Copy link
Contributor

@jstac jstac commented Nov 10, 2025

Summary

This PR adds a new visualization to the Comparative Statics section of the McCall job search model lecture (mccall_model.md). The plot illustrates how the reservation wage changes when the discount factor β is varied.

Changes

New visualization added:

  • Displays the wage offer distribution (Beta-binomial) as a line with markers
  • Shows two vertical lines representing reservation wages:
    • Orange line: reservation wage at β=0.99 (baseline, ~47.32)
    • Green line: reservation wage at β=0.96 (lower patience, ~44.76)
  • Uses matplotlib's default color cycle for consistency
  • Solid lines with linewidth=2 for clear visibility
  • Legend positioned in upper left corner without frame
  • Font sizes increased by 20% for improved readability

Educational value:
The visualization clearly demonstrates a key economic insight: when workers become less patient (lower β), they set a lower reservation wage and are more willing to accept jobs sooner. This comparative statics result is fundamental to understanding job search behavior.

Technical details:

  • Plot inserted immediately after the introductory sentence in the Comparative Statics section
  • Code is self-contained and uses existing model infrastructure
  • Tested successfully with python mccall_model.py after conversion via jupytext

Test plan

  • Converted md to py using jupytext --to py mccall_model.md
  • Ran python mccall_model.py successfully
  • Verified plot displays correctly with proper colors, labels, and formatting
  • Confirmed reservation wage calculations are accurate

🤖 Generated with Claude Code

Added a new plot in the Comparative Statics section showing the wage offer distribution with reservation wages before and after changing the discount factor β.

Key changes:
- Plot displays wage offer distribution as a line with markers
- Shows reservation wage for β=0.99 (default) as vertical line
- Shows reservation wage for β=0.96 as vertical line for comparison
- Uses matplotlib default color cycle (blue, orange, green)
- Solid lines with lw=2 for clear visibility
- Legend positioned in upper left without frame
- All font sizes increased by 20% for better readability

The visualization clearly demonstrates how decreasing patience (lower β) reduces the reservation wage, as less patient workers are more willing to accept lower wage offers.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jstac
Copy link
Contributor Author

jstac commented Nov 10, 2025

Additional Implementation Details

Visualization Design Choices

Color scheme:

  • Intentionally uses matplotlib's default color cycle (prop_cycle) to ensure consistency with other plots in the lecture series
  • Colors are explicitly assigned: colors[0] (blue) for distribution, colors[1] (orange) for β=0.99, colors[2] (green) for β=0.96

Beta value selection:

  • Changed from β=0.995 to β=0.96 to create more visual separation between the reservation wage lines
  • The difference of ~2.55 wage units makes the comparative statics effect clearly visible

Typography:

  • All text elements scaled up by 20%:
    • Axis labels: 12pt
    • Tick labels: 11pt
    • Legend: 11pt
  • Ensures readability when lecture is rendered in various formats (HTML, PDF)

Economic Interpretation

The plot demonstrates that:

  • When β decreases from 0.99 to 0.96, the reservation wage drops from ~47.32 to ~44.76
  • This 5.4% decrease in the reservation wage reflects increased impatience
  • More impatient workers (lower β) value future wage offers less, making them willing to accept lower wages today
  • The positioning relative to the wage distribution shows both reservation wages fall near the upper tail, indicating selective job acceptance behavior

Code Quality

  • All computations use existing compute_reservation_wage() function
  • No new dependencies introduced
  • Plot generation is self-contained within a single code cell
  • Follows existing style conventions in the lecture

@github-actions
Copy link

📖 Netlify Preview Ready!

Preview URL: https://pr-685--sunny-cactus-210e3e.netlify.app (0152cd9)

📚 Changed Lecture Pages: mccall_model

Moved @jax.jit decorators from intermediate functions to final calling function for better performance.

Changes:
- Removed @jax.jit from compute_reservation_wage_two()
- Removed @jax.jit from compute_stopping_time()
- Removed @partial(jax.jit, ...) from compute_mean_stopping_time()
- Added @jax.jit to compute_stop_time_for_c()

This allows JAX to see the entire computation graph and perform more aggressive optimizations, resulting in ~3% performance improvement.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@jstac
Copy link
Contributor Author

jstac commented Nov 10, 2025

JAX JIT Optimization

I've added an optimization to improve JAX compilation performance in the McCall model lecture.

Changes

  • Removed @jax.jit from intermediate functions (compute_reservation_wage_two, compute_stopping_time, compute_mean_stopping_time)
  • Added @jax.jit to the final calling function (compute_stop_time_for_c)

Why This is Better

When you jit only the final function instead of intermediate functions:

  • JAX can see the entire computation graph at once
  • Enables more aggressive cross-function optimizations
  • Avoids overhead from multiple compilation boundaries

Performance Improvement

Testing shows this approach delivers ~3% faster execution with identical numerical results (verified with comparison tests).

This follows JAX best practices for optimal compilation and performance.

@github-actions
Copy link

📖 Netlify Preview Ready!

Preview URL: https://pr-685--sunny-cactus-210e3e.netlify.app (8537557)

📚 Changed Lecture Pages: mccall_model

@jstac jstac merged commit 459ffcb into main Nov 10, 2025
1 check passed
@jstac jstac deleted the mccall_se branch November 10, 2025 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants